import time
import datetime

gmtime = time.gmtime()
print(gmtime)
# 格式化时间
ftime = time.strftime('%Y-%m-%d %H:%M:%S', gmtime)
print(ftime)

print(time.time())  # 某年至今的秒数
d = datetime.datetime.fromtimestamp(time.time())  # 转换成年月日格式
print(d)

t = datetime.time(15, 12, 25)   # 自定义时分秒
print(t)

today = datetime.date.today()   # 获取今天日期（年月日）
print(today.year)   # 获取年份
onday = datetime.timedelta(days=1)  # 一天
print(today-onday)  # 减去一天
